package com.primary.string;

/**
 * @author: yyh
 * @description:反转字符串：https://leetcode.cn/leetbook/read/top-interview-questions-easy/xnhbqj/
 * @date: 2022/7/14 16:52
 */
public class ReverseString {

    public static void main(String[] args) {

    }

    /**
     * 示例 1：
     * <p>
     * 输入：s = ["h","e","l","l","o"]
     * 输出：["o","l","l","e","h"]
     * 示例 2：
     * <p>
     * 输入：s = ["H","a","n","n","a","h"]
     * 输出：["h","a","n","n","a","H"]
     * <p>
     * 空间：O(1)
     */

    public void reverseString(char[] s) {
        char t;
        for (int i = 0; i < s.length / 2; i++) {
            t = s[s.length - i - 1];
            s[s.length - i - 1]  = s[i];
            s[i] = t;
        }
    }
}
